// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
mod fs_file;
// mod chat;
// use crate::chat::chat_tool;
use crate::fs_file::fs_tool;
use fs_file::models::DataResponse;
#[tauri::command]
fn addMes(path: &str,json_data:&str) -> String {
    let mut  result_mes = "OK";
    let mut log_data_params = json_data.to_string();
    let json_data = r#json_data;
    fs_tool::exist_init_file(path);
    fs_tool::add_log(path,json_data);
    format!("{}", &result_mes)
}
#[tauri::command]
fn deleteMes(path: &str,json_data:&str) -> String {
    let mut  result_mes = "OK";
    let json_data = r#json_data;
    fs_tool::delete_log(path,json_data);
    format!("{}", &result_mes)
}
#[tauri::command]
fn addUser(path: &str,json_data:&str) -> String {
    let mut  result_mes = "OK";
    let mut log_data_params = json_data.to_string();
    let json_data = r#json_data;
    fs_tool::exist_init_file(path);
    fs_tool::add_user(path,json_data);
    format!("{}", &result_mes)
}
#[tauri::command]
fn editUser(path: &str,json_data:&str) -> String {
    let mut  result_mes = "OK";
    let mut log_data_params = json_data.to_string();
    let json_data = r#json_data;
    fs_tool::exist_init_file(path);
    fs_tool::edit_user(path,json_data);
    format!("{}", &result_mes)
}
#[tauri::command]
fn deleteUser(path: &str,json_data:&str) -> String {
    let mut  result_mes = "OK";
    let mut log_data_params = json_data.to_string();
    let json_data = r#json_data;
    fs_tool::exist_init_file(path);
    fs_tool::delete_user(path,json_data);
    format!("{}", &result_mes)
}
#[tauri::command]
fn initlist(path: &str) -> Result<DataResponse, String> {
    fs_tool::exist_init_file(path);
    fs_tool::get_all_data(path)
}
#[tauri::command]
fn getCurrentUser(path: &str) -> String{
    let mut   result_mes = "";

    format!("{}", &result_mes)
}
#[tauri::command]
fn setCurrentUser(path: &str) -> String{
    let    result_mes = "OK";

    format!("{}", &result_mes)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![getCurrentUser,setCurrentUser,addMes,initlist,deleteMes,addUser,editUser,deleteUser])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
